<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets" template="/home.xhtml">
	<ui:define name="corpo">
		<h:form>
			<p:panel header="Área do Médico" style="background: #dbfbda;font-size:15px;min-height:700px;margin-top:10px;float:left;width:99%">
				<h:panelGroup style="float: left;width:250px;" layout="block">
					<ui:include src="menu_esquerda.xhtml" />	
				</h:panelGroup>
				
				<h:panelGroup layout="block" style="float:left">
					<p:panel header="Próximas consultas" style="width:680px">
						<h:panelGroup layout="block">
							
							<p:spacer height="15" />
							<h:panelGroup layout="block">
								<p:dataTable id="tabelaConsultasMarcadas" value="#{controleMeidicoBean.consultasEmAberto}" var="entity" paginator="true" rows="10" emptyMessage="Não há consultas marcadas"
							                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}" 
							                 paginatorPosition="bottom">
							    	<f:facet name="header">
							    		<h:panelGroup layout="block" style="text-align:left">
							    			<h:outputText value="Minhas Consultas" />
							    		</h:panelGroup>							    		
							    	</f:facet>
							    	
								    <p:column style="padding:10px;font-size:12px">
								    	<f:facet name="header">
								    		<h:outputText value="Consultas atribuídas a Dr(a): #{usuarioLogadoBean.form.usuario.nome}" style="font-weight:bold" />
								    	</f:facet>
									    <h:panelGroup layout="block">
											
											<h:panelGroup layout="block" style="float:left;width:220px;margin-top:7px;">
												<h:panelGroup style="height:2px" layout="block">
													<h:outputText value="Nome: " styleClass="fmtCampoConsulta" />
													<h:outputText value="#{entity.paciente.nome}" />
												</h:panelGroup>
												<br />
												<h:panelGroup style="height:2px" layout="block">
													<h:outputText value="Email: " styleClass="fmtCampoConsulta" />
													<h:outputText value="#{entity.paciente.email}" style="font-style: italic;" />
												</h:panelGroup>
												<br />
												<h:panelGroup style="height:2px" layout="block">
													<h:outputText value="Telefone: " styleClass="fmtCampoConsulta" />
													<h:outputText converter="com.automed.marcaraFoneConverter" value="#{entity.paciente.telefones.get(0).telefone}" />
												</h:panelGroup>		
											</h:panelGroup>
											
											<h:panelGroup layout="block" style="float:left;width:140px;margin-top:7px;">
												<h:panelGroup style="height:2px" layout="block">
													<h:outputText value="Data: " styleClass="fmtCampoConsulta" />
													<h:outputText value="#{entity.dataConsulta}">
														<f:convertDateTime pattern="dd/MM/yyyy" locale="pt_BR" timeZone="GMT-3"/>
													</h:outputText>
												</h:panelGroup>
												<br />
												<h:panelGroup style="height:2px" layout="block">
													<h:outputText value="Horário: " styleClass="fmtCampoConsulta" />
													<h:outputText value="#{entity.dataConsulta}">
														<f:convertDateTime pattern="HH:mm" locale="pt_BR" timeZone="GMT-3"/>
													</h:outputText>
												</h:panelGroup>
												<br />
												<h:panelGroup style="height:2px" layout="block">
													<h:outputText value="Idade: " styleClass="fmtCampoConsulta" />
													<h:outputText value="#{entity.paciente.idade}" />
												</h:panelGroup>
												<h:panelGroup style="height:2px;">
													
												</h:panelGroup>
														
											</h:panelGroup>
											
											<h:panelGroup layout="block" style="width:150px;float:left;margin-top:6px;">
												<h:panelGroup layout="block" style="width:100%;text-align:center">
													<p:commandLink style="text-decoration:none;" onerror="alert('ERRO')">
														<h:graphicImage style="border:none" library="image" name="marcar.png" />
														<br />
														<h:outputText style="color:#3B6704;font-weight:bold" value="Atender Paciente" />														
													</p:commandLink>		
												</h:panelGroup>
											</h:panelGroup>
											
											<h:panelGroup layout="block" style="width:120px;float:left;margin-top:9px;">												
												<h:panelGroup layout="block" style="text-align:center">
													<h:graphicImage width="45" height="45" library="image" name="warning.png" />
													<br />
													<h:outputText style="font-size:9px" value="Aguadando atendimento." />
												</h:panelGroup>
											</h:panelGroup>
										</h:panelGroup>	
									</p:column>
							    	
							    	             
				                </p:dataTable>
							</h:panelGroup>
						</h:panelGroup>
						<p:spacer height="15" />
					</p:panel>
				</h:panelGroup>
				
			</p:panel>
		</h:form>
		
		<p:dialog header="Aviso" widgetVar="modalAlerta" resizable="false" modal="true" width="400" showEffect="clip" hideEffect="fold">
			<h:form>
				<h:panelGroup layout="block" style="text-align:center">
					<h:graphicImage library="image" name="alert.png" />
				</h:panelGroup>
				<h:panelGroup layout="block" style="text-align:center">
					<h:outputText value="Atenção, você possui consulta agendada para hoje!" style="font-size:16px;color:#D5980B" />
				</h:panelGroup>
				<br />
				<h:panelGroup layout="block" style="text-align:center">
					<p:commandButton value="Ciente" onclick="modalAlerta.hide();" style="font-size:14px" />
				</h:panelGroup>
			</h:form>
		</p:dialog>
		
        <script type="text/javascript">

            function verificaDiaConsulta(){

                if(#{controleMeidicoBean.verificaConsultaMarcada}){
                	modalAlerta.show();
                }            	
            }
        </script>
		
	</ui:define>
</ui:composition>